<?php

class QuydinhController extends Zend_Controller_Action {

	//Mang tham so nhan duoc o moi Action
	protected $_arrParam;

	//Duong dan cua Controller
	protected $_currentController;

	//Duong dan cua Action chinh
	protected $_actionMain;

	//Thong so phan trang
	protected $_paginator = array('itemCountPerPage' => 5, 'pageRange' => 3);
	protected $_namespace;
	
	public function init() {
		$file_uri = $this->view->baseUrl(DEFAULT_PATH . '/js/jquery.dd.js');
	
		// Meta
		$this->view->headMeta()->setName('description', 'Trang web chuyên về thông tin phòng trọ.');
		$this->view->headMeta()->appendName('keywords', 'phòng trọ, phòng cho thuê, thuê phòng, nhà trọ');

		//Mang tham so nhan duoc o moi Action
		$this->_arrParam = $this->_request->getParams();

		//Duong dan cua Controller
		$this->_currentController = '/' . $this->_arrParam['module'] . '/' . $this->_arrParam['controller'];

		//Duong dan cua Action chinh
		$this->_actionMain = '/' . $this->_arrParam['module'] . '/' . $this->_arrParam['controller'] . '/index';

		$this->_paginator['currentPage'] = $this->_request->getParam('page', 1);
		$this->_arrParam['paginator'] = $this->_paginator;

		//Luu cac du lieu filter vao SESSION
		//Dat ten SESSION
		$this->_namespace = $this->_arrParam['module'] . '-' . $this->_arrParam['controller'];
		
		//Truyen ra view
		$this->view->arrParam = $this->_arrParam;
		$this->view->currentController = $this->_currentController;
		$this->view->actionMain = $this->_actionMain;
		
		$model = new Default_Model_ThongTinCtyMapper();
		$thong_tin_cty = $model->fetchAll();
		$this->view->thong_tin_cty = $thong_tin_cty;
	}

	public function indexAction() {
		
		// Title
		$this->view->headTitle('Quy định');
		$paginator = new Zendhlt_Paginator();
		
		// Get items tin mới của table Ptr_Tin_Rao
		$model = new Default_Model_PtrTinRaoMapper();
		$items = $model->fetch($this->_arrParam, 'trang_thai = 1', 5, array(array('colName' => 'ngay_dang', 'order' => 'DESC')), 'list');
		
		$this->view->itemsNewPtrTinTro = $items;
		
		// Get items tin hot của table Ptr_Tin_Rao
		$model = new Default_Model_PtrTinRaoMapper();
		$items = $model->fetch($this->_arrParam, 'trang_thai = 1', 5, array(array('colName' => 'luot_xem', 'order' => 'DESC')), 'list');
		
		$this->view->itemsHotPtrTinTro = $items;
		
		// Get items tin nổi bật của table Tin_Tuc
		$model = new Default_Model_TinTucMapper();
		$items = $model->fetchBy('trang_thai = 1', array(array('colName' => 'luot_xem', 'order' => 'DESC')), 1, 5, 'list');
		
		$this->view->itemsHotTinTuc = $items;
		
	}
}